﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Linq.Expressions;

namespace GroceryPriceBook.Core
{
	/// <summary>
	/// Common methods provided through a static class
	/// </summary>
	public static class Common
	{
		/// <summary>
		/// get the name of a class property to a string
		/// http://stackoverflow.com/questions/4266426/c-sharp-how-to-get-the-name-in-string-of-a-class-property
		/// </summary>
		/// <typeparam name="T"></typeparam>
		/// <param name="expr"></param>
		/// <returns></returns>
		public static string NameOf<T>(Expression<Func<T>> expr)
		{
			return ((MemberExpression)expr.Body).Member.Name;
		}
	}
}